package com.ymatou.iapi.systemnotice.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.ymatou.iapi.systemnotice.service.NoticeListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.OP_NoticeInfo;
import com.ymttest.database.sqlwapper.YmtCsWapper;
/**
*查询通知明细
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_NoticeList{
	private static NoticeListCall NoticeListCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询通知明细");
	}

	@Before
	public void caseUp() {
		NoticeListCall=new NoticeListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(NoticeListCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_NoticeList_001() {
		Logger.start(true,"查询通知列表成功");
		try {
			NoticeListCall.callService();			
			Logger.verifyEquals("true", NoticeListCall.getString("Success"), "验证Success");
			 JsonArray results = NoticeListCall.getJsonObject().get("Result").getAsJsonArray();
			for (JsonElement result : results) {
				OP_NoticeInfo ni = new YmtCsWapper().selectNoticeInfoByNoticeid(result.getAsJsonObject().get("NoticeId").getAsString()).get(0);
				Logger.verifyEquals(ni.getNoticeId(), result.getAsJsonObject().get("NoticeId").getAsString(), "验证NoticeId");
				Logger.verifyEquals(ni.getBriefTitle(), result.getAsJsonObject().get("BriefTitle").getAsString(), "验证BriefTitle");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}